GBML manual / Collision

tile_solid

The body question: true if the tile at (x, y) blocks a body - every tile class except TILE_PASS (TILE_SOLID and TILE_LOW_COVER both block a body; see tile_class). What a project’s own generated call should use for any object NOT declared is_projectile.

Syntax

tile_solid(x, y) -> bool

Arguments

NameType
xreal
yreal

Returns

bool

Description

The body question: true if the tile at (x, y) blocks a body - every tile class except TILE_PASS (TILE_SOLID and TILE_LOW_COVER both block a body). Decoded from tile_flags's class bits for the common case most movement code actually wants, without pulling the full flag byte apart by hand.

A One-way platform is open here: tile_solid is false on a One-way square, from every side. tile_one_way is the call that sees one.

x and y are a place in the room, counted from the room's top-left corner. That is also where the tile grid starts, so the very first tile covers x from 0 to 7 and y from 0 to 7 (tiles are 8 by 8 pixels).

This is what a project's own generated code should call for any object that is not declared is_projectile - an object that is should call tile_blocks_projectile instead, since TILE_LOW_COVER answers the two questions differently.

If the tile is a slope, the answer is for the one pixel under the point: true only where the shape is solid. A point over the empty corner of a ramp square is not blocked, and one just under the line of the ramp is.

This looks at one tile, under one point. That is right for something tiny, like a bullet. It is the wrong tool for anything with size that moves: a 16 by 16 box covers four tiles or more, and one point cannot see its corners. For that, ask tile_free, which checks the instance's whole box.

Example

if (tile_solid(x + hsp, y)) {
    hsp = 0;
}

Stops the walker's own horizontal motion the instant the tile ahead is flagged solid - the same bit tile_flags(x + hsp, y) & 1 would answer, already decoded.

See also: tile_flagstile_classtile_blocks_projectiletile_freetile_shapeSlopes